<#import "/admin/_layout.html" as layout>
<@layout.header "分类编辑"></@layout.header>
<@layout.body>
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-left">
                        <li class="breadcrumb-item"><a href="#">分类</a></li>
                        <li class="breadcrumb-item active">新增</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <section class="content">
        <div class="container-fluid">
            <div class="card card-default">
                <form id="myForm" method="POST" action="/admin/product/category/doSave" ok="/admin/product/category/list">
                    <input type="hidden" name="id" value="${(productCategory.id)!}">
                    <div class="card-body">
                        <div class="form-group">
                            <label for="roleName">分类名称</label>
                            <input type="text" name="title" class="form-control" id="title" placeholder="请输入分类名称" value="${(productCategory.title)!}">
                        </div>
                        <div class="form-group">
                            <label for="parentId">父级分类</label>
                            <select class="form-control" id="parentId" name="parentId">
                                <#if productCategoryList?? &&(productCategoryList?size>0)>
                                    <option value="">请选择</option>
                                    <#list productCategoryList as item>
                                        <#if productCategory??>
                                            <#if (item.id != productCategory.id)>
                                                <option value="${item.id}" <#if productCategory.parentId?? && productCategory.parentId==item.id>selected</#if>>${(item.title)!}</option>
                                            </#if>
                                        <#else>
                                            <option value="${item.id}">${(item.title)!}</option>
                                        </#if>
                                    </#list>
                                </#if>
                            </select>
                        </div>
                        <div class="form-group">
                            <#assign _type=(productCategory.type)!"category" />
                            <label for="type">类型</label>
                            <select class="form-control" id="type" name="type">
                                <option value="category" <@selectedIf value=(_type =="category")/>>分类</option>
                                <option value="tag" <@selectedIf value=(_type =="tag")/>>标签</option>
                            </select>
                        </div>
                        <div class="box box-solid" style="width: 200px;">
                            <div class="box-header with-border ">
                                <label for="thumbnail">图标</label>
                            </div>
                            <div class="box-body no-padding">
                                <img src="/static/${(productCategory.icon)!'/img/default.jpg'}"
                                     style="width: 100%;height: 200px"
                                     id="thumbnail">
                                <input type="hidden" value="${(productCategory.icon)!}" name="icon" id="articleThumbnail">
                            </div>
                            <div class="box-footer">
                                <button type="button" class="btn-image-browser btn btn-default btn-sm "
                                        for-src="thumbnail"
                                        for-input="articleThumbnail">选择图片
                                </button>
                                <a href="javascript:;" style="padding-left: 15px" id="removeThumbnail">移除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="roleName">排序</label>
                            <input type="number" name="sortNum" class="form-control" id="sortNum" placeholder="请输入分类排序" value="${(productCategory.sortNum)!}">
                        </div>
                        <div class="form-group">
                            <label for="roleName">分类描述</label>
                            <input type="text" name="desc" class="form-control" id="desc" placeholder="请输入分类描述" value="${(productCategory.desc)!}">
                        </div>
                        <div class="form-group">
                            <label for="roleName">页面后缀</label>
                            <input type="text" name="suffix" class="form-control" id="suffix" placeholder="请输入分类后缀" value="${(productCategory.suffix)!}">
                        </div>
                    </div>
                    <div class="card-footer">
                        <button type="submit" class="btn btn-primary">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </section>
</@layout.body>
<@layout.script>
    <script>
        $(function () {
            submitForm({
                title: { required: true}
            },{
                title: {required: "请输入分类名称"}
            })
        });
    </script>
</@layout.script>